module.exports = function (grunt) {

    require('load-grunt-tasks')(grunt);

    grunt.initConfig({

        clean: {
            all: 'dist'
        },
        copy: {
            html: {
                src: 'public/*.html',
                dest: 'dist/',
                flatten: true,
                expand: true
            },
            view: {
                src: 'public/views/*.html',
                dest: 'dist/views',
                flatten: true,
                expand: true
            }
        },

        useminPrepare: {
            html: ['public/index.html', 'public/run.html'],
            options: {
                dest: 'dist'
            }
        },
        usemin: {
            html: ['dist/index.html', 'dist/run.html']
        },
        filerev: {
            files: {
                src: ['dist/**/*.{js,css}']
            }
        },
        cssUrlEmbed: {
            dist: {
                options: {
                    baseDir: 'public'
                },
                files: {
                    'dist/app/app.min.css': ['dist/app/app.min.css']
                }
            }
        },
        replace: {
            dist: {
                options: {
                    patterns: [
                        {
                            match: 'data:text/plain',
                            replacement: 'data:image/svg+xml'
                        }
      ],
                    usePrefix: false
                },
                files: {
                    'dist/app/app.min.css': ['dist/app/app.min.css']
                }
            }
        },

        uncss: {
            dist: {
                files: {
                    'dist/app/1.css': ['dist/index.html', 'dist/views/*.html']
                }
            }
        }




    });



    grunt.registerTask('default', ['clean', 'copy', 'useminPrepare', 'concat:generated', 'cssmin:generated', 'uglify:generated', 'cssUrlEmbed', 'replace', 'filerev', 'usemin']);
};
